package com.stu.serive.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.stu.mapper.CounsellorManageMapper;
import com.stu.pojo.Counsellor;
import com.stu.pojo.Emp;
import com.stu.pojo.Notice;
import com.stu.pojo.PageBean;
import com.stu.serive.CounsellorManageService;
import com.stu.serive.aTService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class CounsellorManageImpl implements CounsellorManageService {

    @Autowired
    private CounsellorManageMapper counsellorManageMapper;

    /**
     * 删除辅导员信息
     * @param ids
     */
    public void deleteCounsellorManage(List<Integer> ids) {
        counsellorManageMapper.deleteCounsellorManage(ids);
    }

    /**
     * 分页查询辅导员信息
     * @param page
     * @param pageSize
     * @param emp
     * @return
     */
    public PageBean selectCounsellorInformation(Integer page, Integer pageSize, Counsellor emp) {
        //使用pageheleper
        //1.设置分页参数
        PageHelper.startPage(page, pageSize);
        //2.执行查询
        List<Counsellor> empList = counsellorManageMapper.selectCounsellorInformation(emp);
        log.info("empList:{}",empList);
        //获得查询后的内容
        Page<Counsellor> p = (Page<Counsellor>) empList; //将emplist转换类型为page并且封装在p中
        //3.封装PageBean对象
        PageBean pageBean = new PageBean(p.getTotal(), p.getResult());
        return pageBean;
    }
}
